/*
ALTERNATIVE EMAIL NOTIFICATOR
This plugin change the default way to notify

Developers:
The working of the plugin is simple. 

Known errors:


I thanks if you correct something what it was wrong. My english is poor. Because of that, you can correct me too.

*/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

/* config.h may define PURPLE_PLUGINS; protect the definition here so that we
 * don't get complaints about redefinition when it's not necessary. */
#ifndef PURPLE_PLUGINS
# define PURPLE_PLUGINS
#endif

#include <glib.h>

/* This will prevent compiler errors in some instances and is better explained in the
 * how-to documents on the wiki */
#ifndef G_GNUC_NULL_TERMINATED
# if __GNUC__ >= 4
#  define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
# else
#  define G_GNUC_NULL_TERMINATED
# endif
#endif

#include <notify.h>
#include <plugin.h>

#include "version.h"
#include "internal.h"
#include "plugin.h"
#include "pluginpref.h"
#include "prefs.h"


static PurplePluginPrefFrame *
get_plugin_pref_frame(PurplePlugin *plugin) {

	
	int i = 0;		
	PurplePluginPrefFrame *frame;
	PurplePluginPref *ppref;
	frame = purple_plugin_pref_frame_new();
	ppref = purple_plugin_pref_new_with_name_and_label(
							"/plugins/core/language_change/language",
							"Select language");
	purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);

	get_file_names("/usr/lib/locale/", &file_names);

while(i <  file_names.number_of_strings - 5)
{
	purple_plugin_pref_add_choice(ppref, file_names.string_pointers[i], file_names.string_pointers[i]);	
	i++;
}
	purple_plugin_pref_frame_add(frame, ppref);
	return frame;
}


static gboolean
plugin_load (PurplePlugin * plugin)
{
	const char *lang = purple_prefs_get_string("/plugins/core/language_change/language");
				
	return TRUE;
}

static PurplePluginUiInfo prefs_info = {
	get_plugin_pref_frame,
	0,   /* page_num (Reserved) */
	NULL, /* frame (Reserved) */
	/* Padding */
	NULL,
	NULL,
	NULL,
	NULL
};

static PurplePluginInfo info = {
	PURPLE_PLUGIN_MAGIC,
	PURPLE_MAJOR_VERSION,
	PURPLE_MINOR_VERSION,
	PURPLE_PLUGIN_STANDARD,
	NULL,
	0,
	NULL,
	PURPLE_PRIORITY_DEFAULT,

	"core-language_change",
	"Language change",
	"1.0",
	"Language change plugin",
	"It changes the default language of pidgin",
	"Carlos-Helder García Escobar", 
	"http://code.google.com/p/language-change-pidgin-plugin/", 
	plugin_load,
	NULL,
	NULL,
	NULL,
	NULL,
	&prefs_info,
	NULL,		
	NULL,
	NULL,
	NULL,
	NULL
};

static void
init_plugin (PurplePlugin * plugin)
{
	purple_prefs_add_none("/plugins/core/language_change");
	purple_prefs_add_string("/plugins/core/language_change/language", "default");
}

PURPLE_INIT_PLUGIN (language_change, init_plugin, info)
